<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.2">
<title>Legacy Domain Model</title>
<link rel="stylesheet" href="./css/hibernate.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js"></script>
<script>document.addEventListener('DOMContentLoaded', prettyPrint)</script>
</head>
<body class="article">
<div id="header">
</div>
<div id="content">
<div class="sect1">
<h2 id="appendix-legacy-domain-model">Legacy Domain Model</h2>
<div class="sectionbody">
<div class="exampleblock">
<div class="title">Example 1. Declaring a version property in <code>hbm.xml</code></div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml">&lt;!--
  ~ Hibernate, Relational Persistence for Idiomatic Java
  ~
  ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
  ~ See the lgpl.txt file in the root directory or &lt;http://www.gnu.org/licenses/lgpl-2.1.html&gt;.
  --&gt;
&lt;version
    column="version_column"
    name="propertyName"
    type="typename"
    access="field|property|ClassName"
    unsaved-value="null|negative|undefined"
    generated="never|always"
    insert="true|false"
    node="element-name|@attribute-name|element/@attribute|."
/&gt;</code></pre>
</div>
</div>
</div>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: %;">
<col style="width: %;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">column</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The name of the column holding the version number. Optional, defaults to the property name.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The name of a property of the persistent class.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">type</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The type of the version number. Optional, defaults to <code>integer</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">access</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Hibernate&#8217;s strategy for accessing the property value. Optional, defaults to <code>property</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">unsaved-value</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates that an instance is newly instantiated and thus unsaved.
This distinguishes it from detached instances that were saved or loaded in a previous session.
The default value, <code>undefined</code>, indicates that the identifier property value should be used. Optional.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">generated</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Indicates that the version property value is generated by the database. Optional, defaults to <code>never</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">insert</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Whether or not to include the <code>version</code> column in SQL <code>insert</code> statements.
Defaults to <code>true</code>, but you can set it to <code>false</code> if the database column is defined with a default value of <code>0</code>.</p></td>
</tr>
</tbody>
</table>
<div class="exampleblock">
<div class="title">Example 2. The timestamp element in <code>hbm.xml</code></div>
<div class="content">
<div class="listingblock">
<div class="content">
<pre class="prettyprint highlight"><code class="language-xml" data-lang="xml">&lt;!--
  ~ Hibernate, Relational Persistence for Idiomatic Java
  ~
  ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
  ~ See the lgpl.txt file in the root directory or &lt;http://www.gnu.org/licenses/lgpl-2.1.html&gt;.
  --&gt;
&lt;timestamp
    column="timestamp_column"
    name="propertyName"
    access="field|property|ClassName"
    unsaved-value="null|undefined"
    source="vm|db"
    generated="never|always"
    node="element-name|@attribute-name|element/@attribute|."
/&gt;</code></pre>
</div>
</div>
</div>
</div>
<table class="tableblock frame-all grid-all spread">
<colgroup>
<col style="width: %;">
<col style="width: %;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">column</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The name of the column which holds the timestamp. Optional, defaults to the property name</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">name</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The name of a JavaBeans style property of Java type <code>Date</code> or <code>Timestamp</code> of the persistent class.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">access</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The strategy Hibernate uses to access the property value. Optional, defaults to <code>property</code>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">unsaved-value</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A version property which indicates than instance is newly instantiated, and unsaved.
This distinguishes it from detached instances that were saved or loaded in a previous session.
The default value of <code>undefined</code> indicates that Hibernate uses the identifier property value.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">source</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Whether Hibernate retrieves the timestamp from the database or the current JVM.
Database-based timestamps incur an overhead because Hibernate needs to query the database each time to determine the incremental next value.
However, database-derived timestamps are safer to use in a clustered environment.
Not all database dialects are known to support the retrieval of the database&#8217;s current timestamp.
Others may also be unsafe for locking because of lack of precision.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">generated</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Whether the timestamp property value is generated by the database. Optional, defaults to <code>never</code>.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2017-02-16 12:14:38 +01:00
</div>
</div>
</body>
</html>